#ifndef __BOOTLOADER_H
#define __BOOTLOADER_H
#include "stdint.h"

#define   MCU_UPGRADE_MAGIC_NUM    0x4D435546

typedef  void (*pFunction)(void);

typedef struct mcu_img_head {
	unsigned int magic;
	unsigned int len;
	unsigned int img_crc;
	unsigned int ver;
	unsigned int reserved[59];
	unsigned int header_crc;
}mcu_img_header_t;


#define  MCU_FIRMWARE_HEADER_LEN                 (sizeof(struct mcu_img_head))
#define  MCU_FIRMWARE_HEADER_WITHOUT_CRC_LEN     (sizeof(struct mcu_img_head) - sizeof(unsigned int))
#define  MAX_FIRMWARE_LEN                        0x8000

typedef enum {
	MCU_FIRMWARE_VRESION_EQUAL = 0U,
	MCU_FIRMWARE_VRESION_NOT_EQUAL
}MCU_VerState;

typedef enum
{
	MCU_FIRMWARE_HEADER_CRC_OK = 0U,
	MCU_FIRMWARE_HEADER_CRC_FAIL
}HeaderCrcState;

typedef enum
{
	MCU_FIRMWARE_IMAGE_CRC_OK = 0U,
	MCU_FIRMWARE_IMAGE_CRC_FAIL 
}ImageCrcState;

typedef enum
{
	MCU_FIRMWARE_CHECK_OK = 0U,
	MCU_FIRMWARE_CHECK_FAIL
}FirmwareState;

void mcu_firmware_bootloader(void);
#endif
